<?xml version="1.0" encoding="windows-1250"?>
<gxsl:stylesheet xmlns:gxsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/TransformAlias" xml:space="default">
  <gxsl:namespace-alias stylesheet-prefix="xsl" result-prefix="gxsl"/>
  <gxsl:output method="xml" encoding="windows-1250" cdata-section-elements="gxsl:comment" indent="yes"/>
  
  <gxsl:param name="cvincludepage"/>
  <gxsl:param name="cvinclude" select="$cvincludepage/.."/>
  <gxsl:param name="lang">cs</gxsl:param>

  <gxsl:template match="/">
    <xsl:stylesheet version="1.0">
      <xsl:output method="text" indent="no" encoding="windows-1250"/>
      <gxsl:apply-templates select="$cvinclude"/>
    </xsl:stylesheet>
  </gxsl:template>

  <gxsl:template match="CVInclude">

    <gxsl:variable name="dict" select="document('dictionary.xml')/Translation"/>


      <xsl:template match="DPNavig">
        <gxsl:if test="../../../CVITitles/CVITitle[@id_cttype='maintitle']/Title">
          <gxsl:value-of select="../../../CVITitles/CVITitle[@id_cttype='maintitle']/Title"/><xsl:text><gxsl:text>	</gxsl:text></xsl:text>
        </gxsl:if>
        <gxsl:choose>
          <gxsl:when test="count(../../../CVIProperties/CVIProperty[@onlabel='1'])!=0">
            <gxsl:for-each select="../../../CVIProperties/CVIProperty[@onlabel='1']">
    
              <gxsl:choose>            
                <gxsl:when test="PropGroup/@basegroup='true'">
                
                  <gxsl:variable name="concept">
                    <gxsl:choose>
                      <gxsl:when test="RefProp">  
                        <gxsl:value-of select="../../@concept"/>
                      </gxsl:when>
                      <gxsl:otherwise>
                        <gxsl:value-of select="@concept"/>
                      </gxsl:otherwise>
                    </gxsl:choose>
                  </gxsl:variable>
        
                  <gxsl:variable name="attr">
                    <gxsl:choose>
                      <gxsl:when test="RefProp">  
                        <gxsl:choose>
                          <gxsl:when test="RefProp[1]/@attr='1'"> 
                            <gxsl:value-of select="'@'"/>
                          </gxsl:when>
                          <gxsl:otherwise>
                            <gxsl:value-of select="''"/>
                          </gxsl:otherwise>
                        </gxsl:choose>
                      </gxsl:when>
                      <gxsl:when test="@attr='1'">
                        <gxsl:value-of select="'@'"/>
                      </gxsl:when>
                      <gxsl:otherwise>
                        <gxsl:value-of select="''"/>
                      </gxsl:otherwise>
                    </gxsl:choose>
                  </gxsl:variable>
        
                  <gxsl:variable name="name">
                    <gxsl:choose>
                      <gxsl:when test="RefProp">  
                        <gxsl:choose>
                          <gxsl:when test="RefProp[1]/@attr='1'"> 
                            <gxsl:value-of select="RefProp[1]/@nicknamelow"/>
                          </gxsl:when>
                          <gxsl:otherwise>
                            <gxsl:value-of select="RefProp[1]/@nickname"/>
                          </gxsl:otherwise>
                        </gxsl:choose>
                      </gxsl:when>
                      <gxsl:when test="@attr='1'">
                        <gxsl:value-of select="@lowname"/>
                      </gxsl:when>
                      <gxsl:otherwise>
                        <gxsl:value-of select="@name"/>
                      </gxsl:otherwise>
                    </gxsl:choose>
                  </gxsl:variable>
        
                  <xsl:variable name="label">
                    <gxsl:attribute name="select"><gxsl:value-of select="../../@conceptcoll"/>/<gxsl:value-of select="$concept"/>/<gxsl:value-of select="$attr"/><gxsl:value-of select="$name"/></gxsl:attribute>
                  </xsl:variable>
        
                     <xsl:value-of select="$label"/><xsl:text><gxsl:text>	</gxsl:text></xsl:text>
    
                </gxsl:when>
                <gxsl:otherwise>
    
                  <gxsl:variable name="concept">
                    <gxsl:value-of select="../../@concept"/>
                  </gxsl:variable>
        
                  <gxsl:variable name="attr">
                    <gxsl:choose>
                      <gxsl:when test="RefProp">  
                        <gxsl:choose>
                          <gxsl:when test="RefProp[1]/@attr='1'"> 
                            <gxsl:value-of select="'@'"/>
                          </gxsl:when>
                          <gxsl:otherwise>
                            <gxsl:value-of select="''"/>
                          </gxsl:otherwise>
                        </gxsl:choose>
                      </gxsl:when>
                      <gxsl:when test="@attr='1'">
                        <gxsl:value-of select="'@'"/>
                      </gxsl:when>
                      <gxsl:otherwise>
                        <gxsl:value-of select="''"/>
                      </gxsl:otherwise>
                    </gxsl:choose>
                  </gxsl:variable>
        
                  <gxsl:variable name="name">
                    <gxsl:choose>
                      <gxsl:when test="RefProp">  
                        <gxsl:choose>
                          <gxsl:when test="RefProp[1]/@attr='1'"> 
                            <gxsl:value-of select="RefProp[1]/@nicknamelow"/>
                          </gxsl:when>
                          <gxsl:otherwise>
                            <gxsl:value-of select="RefProp[1]/@nickname"/>
                          </gxsl:otherwise>
                        </gxsl:choose>
                      </gxsl:when>
                      <gxsl:when test="@attr='1'">
                        <gxsl:value-of select="@nicknamelow"/>
                      </gxsl:when>
                      <gxsl:otherwise>
                        <gxsl:value-of select="@nickname"/>
                      </gxsl:otherwise>
                    </gxsl:choose>
                  </gxsl:variable>
        
                  <xsl:variable name="label">
                    <gxsl:attribute name="select"><gxsl:value-of select="../../@conceptcoll"/>/<gxsl:value-of select="$concept"/>/<gxsl:value-of select="$attr"/><gxsl:value-of select="$name"/></gxsl:attribute>
                  </xsl:variable>
        
                  <xsl:value-of select="$label"/><xsl:text><gxsl:text>	</gxsl:text></xsl:text>
                               
                </gxsl:otherwise>
              </gxsl:choose>            
              
            </gxsl:for-each>
          </gxsl:when>
          <gxsl:otherwise>
            <gxsl:for-each select="../../../CVIProperties/CVIProperty[PropGroup/@basegroup='true' and @key='1']">
              <xsl:value-of select="{../../@conceptcoll}/{@concept}/@{@lowname}"/><xsl:text><gxsl:text>	</gxsl:text></xsl:text>
            </gxsl:for-each>
          </gxsl:otherwise>
        </gxsl:choose>
      
        <xsl:call-template name="newline"/>

      </xsl:template>

      <xsl:template match="DPList">
        <xsl:text><gxsl:text>#	</gxsl:text></xsl:text>
        <gxsl:for-each select="CVIProperties/CVIProperty[(PropGroup/@select='1' or PropGroup/@detail='1') and (@ondetail='show' or @onedit!='hide')]">
        <gxsl:choose>
          <gxsl:when test="not(RefProp)"><gxsl:value-of select="Title"/><xsl:text><gxsl:text>	</gxsl:text></xsl:text></gxsl:when>
          <gxsl:otherwise><gxsl:for-each select="RefProp"><gxsl:value-of select="../Title"/>: <gxsl:value-of select="Title"/><xsl:text><gxsl:text>	</gxsl:text></xsl:text></gxsl:for-each></gxsl:otherwise> 
        </gxsl:choose>
        </gxsl:for-each>        
        <xsl:call-template name="newline"/>        
        <xsl:apply-templates select="{@conceptcoll}/{@concept}"/> 
      </xsl:template>


      <xsl:template match="{@concept}"> 

        <xsl:value-of select="../../DPPage/@at + position() - 1"/>
        <xsl:text><gxsl:text>	</gxsl:text></xsl:text>

        <gxsl:for-each select="CVIProperties/CVIProperty[(PropGroup/@select='1' or PropGroup/@detail='1') and (@ondetail='show' or @onedit!='hide')]">
          <gxsl:choose>
            <gxsl:when test="not(RefProp)">
              <gxsl:choose>
                <gxsl:when test="@attr='1'">
                  <xsl:call-template name="text">
                   <xsl:with-param name="ptext" select="@{@nicknamelow}"/>
                  </xsl:call-template>
                </gxsl:when>
                <gxsl:otherwise>
                  <xsl:call-template name="text">
                   <xsl:with-param name="ptext" select="{@nickname}"/>
                  </xsl:call-template>
                </gxsl:otherwise>
              </gxsl:choose>
              <xsl:text><gxsl:text>	</gxsl:text></xsl:text>
            </gxsl:when>
            <gxsl:otherwise>
              <gxsl:for-each select="RefProp">
                <gxsl:choose>
                  <gxsl:when test="@attr='1'">
                    <xsl:call-template name="text">
                     <xsl:with-param name="ptext" select="@{@nicknamelow}"/>
                    </xsl:call-template>
                  </gxsl:when>
                  <gxsl:otherwise>
                    <xsl:call-template name="text">
                     <xsl:with-param name="ptext" select="{@nickname}"/>
                    </xsl:call-template>
                  </gxsl:otherwise>
                </gxsl:choose>
                <xsl:text><gxsl:text>	</gxsl:text></xsl:text>
              </gxsl:for-each>
            </gxsl:otherwise> 
          </gxsl:choose>
        </gxsl:for-each>
        <xsl:call-template name="newline"/>
      </xsl:template>

      <xsl:template name="text">
        <xsl:param name="ptext"/>
        <xsl:variable name="cr" select="'&#10;'"/>
        <xsl:choose>
          <xsl:when test="contains($ptext,$cr)">
             <xsl:call-template name="text">
               <xsl:with-param name="ptext" select="concat(substring-before($ptext,$cr),'&#32;',substring-after($ptext,$cr))"/>
             </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
           <xsl:value-of select="$ptext"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>

      <xsl:template name="newline">
<xsl:text>
<gxsl:text>
</gxsl:text>
</xsl:text>
      </xsl:template>
  
  </gxsl:template>
	
</gxsl:stylesheet>